/** 
 * Copyright(C) 2010-2011 <webPrj> LTD. All Rights Reserved.                               
 * Project: webPrj
 * Module ID: <0001>
 * Comments: TODO         
 * JDK version used: <JDK1.6.0_25>                              
 * Author: xiamingxing
 * Create Date：10:36:17
 * Modified By: xiamingxing                              
 * Modified Date: 10:36:17                                  
 * Why & What is modified: <修改原因描述>    
 * Version: V1.0                  
 */
package com.xiamx.platform.util;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URL;
import java.util.Properties;

import com.xiamx.platform.constants.sys.SysConst;

public class FileUtil {
	
	public static Properties props = new Properties();

	public static String getResource(String fileName,String property) {
		InputStream ips;
		try {
			// 得到该类的应用路径
			URL path = FileUtil.class.getResource("/");
			// 得到目录的路径
			String paths = path.getPath();
			// 加载资源文件
			ips = new BufferedInputStream(new FileInputStream(paths + SysConst.SYS_PROPERTIES_PATH + fileName));
			if(props.isEmpty()) {
				props.load(ips);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return props.getProperty(property);
	}
	
	public static void main(String []args) {
		String res = getResource("system.properties","ftp.ip");
		System.out.println(res);
	}
	
}

